﻿using System;

namespace ValidationHelper.Validators
{
    public class StringRangeLengthValidator : StringValidator
    {
        #region Propriedades
        public int MinimumLength { get; set; }
        public int MaximumLength { get; set; }
        #endregion

        #region Construtores
        public StringRangeLengthValidator(string message, Type exceptionType, string stringToValidate, int minimumLength, int maximumLength)
            : base(message, exceptionType, stringToValidate)
        {
            MinimumLength = minimumLength;
            MaximumLength = maximumLength;
        }
        #endregion

        #region Métodos
        protected override bool IsNotValid()
        {
            int length;
            if (string.IsNullOrEmpty(StringToValidate))
            {
                length = 0;
            }
            else
            {
                length = StringToValidate.Length;
            }
            return (!(length >= MinimumLength && length <= MaximumLength));
        }
        #endregion
    }
}
